package com.igeek.shop.web.gouwuche;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.igeek.shop.entity.Product;
import com.igeek.shop.service.ProductService;

public class ProductInfoServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//获取商品ID
		String pid = req.getParameter("pid");
		ProductService service = new ProductService();
		Product product = service.findProductById(pid);
		
		//获取cid
		String cid = req.getParameter("cid");
		
		//currentPage
		String currentPage = req.getParameter("currentPage");
		req.setAttribute("product", product);
		req.setAttribute("cid", cid);
		req.setAttribute("currentPage", currentPage);
		
		
		
		
		//页面跳转
		req.getRequestDispatcher("/product_info.jsp").forward(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req,resp);
	}

	
}
